package cn.sfrog.common.core.domain.entity;

import cn.sfrog.common.annotation.Excel;
import cn.sfrog.common.annotation.Excel.Type;
import cn.sfrog.common.annotation.Excels;
import cn.sfrog.common.core.domain.BaseEntity;
import cn.sfrog.common.xss.Xss;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 用户对象 sys_user
 */
public class SysUser extends BaseEntity {
    private static final long serialVersionUID = 1L;

    public static final SysUser DAO = new SysUser();

    /**
     * 用户ID
     */

    private Long userId;

    @TableField(exist = false)
    private String usersig;


    private String openId;

    /**
     * 部门ID
     */
    @Excel(name = "部门编号" , type = Type.IMPORT)
    private Long deptId;

    /**
     * 用户账号
     */
    @Excel(name = "登录名称")
    private String userName;

    /**
     * 用户昵称
     */
    @Excel(name = "用户名称")
    private String nickName;

    /**
     * 用户邮箱
     */
    @Excel(name = "用户邮箱")
    private String email;

    /**
     * 手机号码
     */
    @Excel(name = "手机号码")
    private String phonenumber;

    @TableField(exist = false)
    @Excel(name = "角色(多个则以、分割)",type = Type.IMPORT)
    private String roleNames;

    /**
     * 用户性别
     */
    private String sex;

    /**
     * 用户头像
     */
    private String avatar;

    /**
     * 密码
     */
    private String password;

    /**
     * 盐加密
     */
    private String salt;

    /**
     * 帐号状态（0正常 1停用）
     */
    private String status;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    private String delFlag;

    /**
     * 最后登录IP
     */
    @Excel(name = "最后登录IP" , type = Type.EXPORT)
    private String loginIp;

    /**
     * 最后登录时间
     */
    @Excel(name = "最后登录时间" , width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss" , type = Type.EXPORT)
    private Date loginDate;

    /**
     * 部门对象
     */
    @Excels({
            @Excel(name = "部门名称" , targetAttr = "deptName" , type = Type.EXPORT),
            @Excel(name = "部门负责人" , targetAttr = "leader" , type = Type.EXPORT)
    })
    private SysDept dept;

    /**
     * 角色对象
     */
    private List<SysRole> roles;

    /**
     * 角色组
     */
    private Long[] roleIds;

    /**
     * 岗位组
     */
    private Long[] postIds;

    /**
     * 角色ID
     */
    private Long roleId;

    /**
     * 用户类型（00系统用户 10=会员 20=陪诊人员 30=护工 40=护士 50=医生 60=客服）
     */
    private String userType;


    /**陪护豆数量*/
    private BigDecimal escortBeanCount;

    /**是否实名（0=否 1=是）*/
    private String isVerified;

    /**身份证正面*/
    private String idCardFront;

    /**身份证背面*/
    private String idCardBack;

    /**真实姓名*/
    private String realName;

    /**身份证号码*/
    private String idCardNumber;

    /**身份证有效期*/
    private String idCardValidDate;

    /**工作年限*/
    private Integer recordNum;

    /**记录数量*/
    private Integer workYears;

    /**等级*/
    private String level;


    /**医院id*/
    private Long hospitalId;
    /**科室id*/
    private Long departmentId;


    /**身份审核状态【0=待审核 1=审核通过 2=审核失败】*/
    private String auditStatus;
    /**身份审核备注*/
    private String auditRemark;



    /**好评率*/
    private BigDecimal favorableRate;



    /**简介*/
    private String introduction;



    /**城市code*/
    private String cityCode;
    /**陪诊等级*/
    private String escortLevel;
    /**父用户id（三级分销）*/
    private Long parentUserId;

    /**顶级用户id （三级分销）*/
    private Long topUserId;

    /**账号注销状态*/
    private String logoutStatus;

    @TableField(exist = false)
    private BigDecimal earnestMoney;

    @TableField(exist = false)
    private String isEarnestMoney;

    @TableField(exist = false)
    private String payStatus;

    @TableField(exist = false)
    @ApiModelProperty("医生身份认证")
    private  String doctorProfessionAuth;

    @TableField(exist = false)
    @ApiModelProperty("认证名称")
    private String professionName;

    @TableField(exist = false)
    @ApiModelProperty("医院名称")
    private String hospitalName;

    @TableField(exist = false)
    @ApiModelProperty("部门名称")
    private String departmentName;


    @TableField(exist = false)
    private String token;



    public SysUser() {

    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public SysUser(Long userId) {
        this.userId = userId;
    }

    public Long getUserId() {
        return userId;
    }

    public String getUsersig() {
        return usersig;
    }

    public void setUsersig(String usersig) {
        this.usersig = usersig;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }



    public boolean isAdmin() {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId) {
        return userId != null && 1L == userId;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    @Xss(message = "用户昵称不能包含脚本字符")
    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Xss(message = "用户账号不能包含脚本字符")
    @NotBlank(message = "用户账号不能为空")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    public String getPhonenumber() {
        return phonenumber;
    }

    public void setPhonenumber(String phonenumber) {
        this.phonenumber = phonenumber;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    @JsonIgnore
    @JsonProperty
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public SysDept getDept() {
        return dept;
    }

    public void setDept(SysDept dept) {
        this.dept = dept;
    }

    public List<SysRole> getRoles() {
        return roles;
    }

    public void setRoles(List<SysRole> roles) {
        this.roles = roles;
    }

    public Long[] getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(Long[] roleIds) {
        this.roleIds = roleIds;
    }

    public Long[] getPostIds() {
        return postIds;
    }

    public void setPostIds(Long[] postIds) {
        this.postIds = postIds;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public String getRoleNames() {
        return roleNames;
    }

    public void setRoleNames(String roleNames) {
        this.roleNames = roleNames;
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }


    public BigDecimal getEscortBeanCount() {
        return escortBeanCount;
    }

    public void setEscortBeanCount(BigDecimal escortBeanCount) {
        this.escortBeanCount = escortBeanCount;
    }

    public String getIsVerified() {
        return isVerified;
    }

    public void setIsVerified(String isVerified) {
        this.isVerified = isVerified;
    }

    public String getIdCardFront() {
        return idCardFront;
    }

    public void setIdCardFront(String idCardFront) {
        this.idCardFront = idCardFront;
    }

    public String getIdCardBack() {
        return idCardBack;
    }

    public void setIdCardBack(String idCardBack) {
        this.idCardBack = idCardBack;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getIdCardNumber() {
        return idCardNumber;
    }

    public void setIdCardNumber(String idCardNumber) {
        this.idCardNumber = idCardNumber;
    }

    public String getIdCardValidDate() {
        return idCardValidDate;
    }

    public void setIdCardValidDate(String idCardValidDate) {
        this.idCardValidDate = idCardValidDate;
    }

    public Integer getRecordNum() {
        return recordNum;
    }

    public void setRecordNum(Integer recordNum) {
        this.recordNum = recordNum;
    }

    public Integer getWorkYears() {
        return workYears;
    }

    public void setWorkYears(Integer workYears) {
        this.workYears = workYears;
    }

    public String getLevel() {
        return level;
    }

    public void setLevel(String level) {
        this.level = level;
    }

    public Long getHospitalId() {
        return hospitalId;
    }

    public void setHospitalId(Long hospitalId) {
        this.hospitalId = hospitalId;
    }

    public Long getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(Long departmentId) {
        this.departmentId = departmentId;
    }

    public String getAuditStatus() {
        return auditStatus;
    }

    public void setAuditStatus(String auditStatus) {
        this.auditStatus = auditStatus;
    }

    public String getAuditRemark() {
        return auditRemark;
    }

    public void setAuditRemark(String auditRemark) {
        this.auditRemark = auditRemark;
    }
    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public BigDecimal getFavorableRate() {
        return favorableRate;
    }

    public void setFavorableRate(BigDecimal favorableRate) {
        this.favorableRate = favorableRate;
    }

    public String getIntroduction() {
        return introduction;
    }

    public void setIntroduction(String introduction) {
        this.introduction = introduction;
    }
    public String getCityCode() {
        return cityCode;
    }

    public void setCityCode(String cityCode) {
        this.cityCode = cityCode;
    }

    public String getEscortLevel() {
        return escortLevel;
    }

    public void setEscortLevel(String escortLevel) {
        this.escortLevel = escortLevel;
    }

    public BigDecimal getEarnestMoney() {
        return earnestMoney;
    }

    public void setEarnestMoney(BigDecimal earnestMoney) {
        this.earnestMoney = earnestMoney;
    }

    public String getIsEarnestMoney() {
        return isEarnestMoney;
    }

    public void setIsEarnestMoney(String isEarnestMoney) {
        this.isEarnestMoney = isEarnestMoney;
    }


    public Long getParentUserId() {
        return parentUserId;
    }

    public void setParentUserId(Long parentUserId) {
        this.parentUserId = parentUserId;
    }

    public Long getTopUserId() {
        return topUserId;
    }

    public void setTopUserId(Long topUserId) {
        this.topUserId = topUserId;
    }

    public String getPayStatus() {
        return payStatus;
    }

    public void setPayStatus(String payStatus) {
        this.payStatus = payStatus;
    }

    public String getDoctorProfessionAuth() {
        return doctorProfessionAuth;
    }

    public void setDoctorProfessionAuth(String doctorProfessionAuth) {
        this.doctorProfessionAuth = doctorProfessionAuth;
    }

    public String getProfessionName() {
        return professionName;
    }

    public void setProfessionName(String professionName) {
        this.professionName = professionName;
    }

    public String getHospitalName() {
        return hospitalName;
    }

    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    public String getLogoutStatus() {
        return logoutStatus;
    }

    public void setLogoutStatus(String logoutStatus) {
        this.logoutStatus = logoutStatus;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("userId" , getUserId())
                .append("usersig" , getUsersig())
                .append("deptId" , getDeptId())
                .append("userName" , getUserName())
                .append("nickName" , getNickName())
                .append("email" , getEmail())
                .append("phonenumber" , getPhonenumber())
                .append("openId" , getOpenId())
                .append("sex" , getSex())
                .append("avatar" , getAvatar())
                .append("password" , getPassword())
                .append("salt" , getSalt())
                .append("status" , getStatus())
                .append("delFlag" , getDelFlag())
                .append("loginIp" , getLoginIp())
                .append("loginDate" , getLoginDate())
                .append("createBy" , getCreateBy())
                .append("createTime" , getCreateTime())
                .append("updateBy" , getUpdateBy())
                .append("updateTime" , getUpdateTime())
                .append("remark" , getRemark())
                .append("dept" , getDept())
                .toString();
    }
}
